package com.example.covid19.util;

import cn.hutool.json.JSONObject;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Date;

@Data
@Slf4j
@Component
public class JiGuangRestSend {
    @Autowired
    OkHttpUtil okHttpUtil;
    public void send(String s) throws IOException {
        JSONObject notification = new JSONObject();
        notification.put("alert", s);
        JSONObject message = new JSONObject();
        message.put("platform", "android");
        message.put("audience", "all");
        message.put("notification", notification);
        String jsonString = message.toString();
        String res = okHttpUtil.doPost("https://api.jpush.cn/v3/push",jsonString,"Authorization","Basic NDgxOGIwNTVkYWY3N2M4MzUzYzg4ZWFhOmIxNjU2YmU2YjljNGQ2N2M5YjU4Njk4YQ==");
        System.out.println(res);
    }
}
